package com.aimaterials.resource.service.impl;

import java.util.List;
import com.aimaterials.common.utils.DateUtils;
import com.aimaterials.common.utils.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.aimaterials.resource.mapper.ResResourceMapper;
import com.aimaterials.resource.domain.ResResource;
import com.aimaterials.resource.service.IResResourceService;

/**
 * 资源Service业务层处理
 * 
 * @author DaemonSu
 * @date 2020-11-10
 */
@Service
public class ResResourceServiceImpl implements IResResourceService 
{
    @Autowired
    private ResResourceMapper resResourceMapper;

    /**
     * 查询资源
     * 
     * @param resourceId 资源ID
     * @return 资源
     */
    @Override
    public ResResource selectResResourceById(Long resourceId)
    {
        return resResourceMapper.selectResResourceById(resourceId);
    }

    /**
     * 查询资源列表
     * 
     * @param resResource 资源
     * @return 资源
     */
    @Override
    public List<ResResource> selectResResourceList(ResResource resResource)
    {
        //有教材id加载
        if(resResource.getStereoscopicId()!=null){
            return resResourceMapper.selectResResourceListBySter(resResource);
        }else{
            //没有教材id加载
            return resResourceMapper.selectResResourceList(resResource);
        }

    }

    /**
     * 查找未处理的资源
     * @param type 资源后缀名
     * @return
     */
    @Override
    public List<ResResource> selectUNResourceList(String type) {
        return resResourceMapper.selectUNResResourceList(type);
    }

    /**
     *
     * @param resResource
     * @return
     */
    @Override
    public int updateVideo(ResResource resResource) {
        return resResourceMapper.updateVideo(resResource);
    }


    /**
     * 新增资源
     * 
     * @param resResource 资源
     * @return 结果
     */
    @Override
    public int insertResResource(ResResource resResource)
    {
        resResource.setCreateTime(DateUtils.getNowDate());
        return resResourceMapper.insertResResource(resResource);
    }

    /**
     * 修改资源
     * 
     * @param resResource 资源
     * @return 结果
     */
    @Override
    public int updateResResource(ResResource resResource)
    {
        resResource.setUpdateTime(DateUtils.getNowDate());
        return resResourceMapper.updateResResource(resResource);
    }

    /**
     * 批量删除资源
     * 
     * @param resourceIds 需要删除的资源ID
     * @return 结果
     */
    @Override
    public int deleteResResourceByIds(Long[] resourceIds)
    {
        return resResourceMapper.deleteResResourceByIds(resourceIds);
    }

    /**
     * 删除资源信息
     * 
     * @param resourceId 资源ID
     * @return 结果
     */
    @Override
    public int deleteResResourceById(Long resourceId)
    {
        return resResourceMapper.deleteResResourceById(resourceId);
    }
}
